﻿@model TypeDocumentation

@using ApiDoc


@{
    ViewBag.Title = Model.Name;
}

<h1>@Model.Name</h1>

<div class="description">
    <p>
    @Model.Description.ToHtml(Url.Action("Index", "ApiDocumentation"))
    </p>
    <div class="remarks">
        @Model.Remarks.ToHtml(Url.Action("Index", "ApiDocumentation"))
    </div>
</div>


<div class="namespace">
    <strong>Namespace:</strong> @Html.ApiDocumentationLink(Model.Namespace)
</div>
<div class="assembly">
    <strong>Assembly:</strong> @Html.ApiDocumentationLink(Model.Assembly)
</div>
@if (Model.ParentType != null) {
    <div class="parentType">
        <strong>Nested Within Type:</strong> @Html.ApiDocumentationLink(Model.ParentType)
    </div>
}

<div class="syntax">
    <h3>Syntax</h3>
    <pre class="brush: csharp">
        @Model.CodeDefinition
    </pre>
</div>

@if (Model.GenericTypeArguments.Any()) {
    <div class="genericTypeArguments">
        <h3>Type Arguments</h3>
        <dl>
            @foreach (var argument in Model.GenericTypeArguments) {
                <dt>@argument.Name</dt>
                <dd>
                    @argument.Description.ToPlainText()
                </dd>
            }
        </dl>
    </div>
}

@{
    // Build a list of base types.
    var parentTree = new List<TypeDocumentation>();
    for (var baseType = Model.BaseType; baseType != null; baseType = baseType.BaseType) {
        parentTree.Insert(0, baseType); // Always put at the start.
    }
}

<div class="inheritenaceHierarchy">
    <h2>Inheritance Hierarchy</h2>

    <ul>
        @* Base Types *@
        @foreach (var type in parentTree) {
            <li>@Html.ApiDocumentationLink(type)</li>
        }

        @* Current Type *@
        <li>@Model.Name</li>
    </ul>
</div>

@if (Model.Classes.Any()) {
    <div class="classes">
        <h2>Classes</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Classes) {
                    <tr>
                        <td>
                            @(item.Modifiers == "public"? String.Empty: item.Modifiers)
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (Model.Interfaces.Any()) {
    <div class="interfaces">
        <h2>Interfaces</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Interfaces) {
                    <tr>
                        <td>
                            @(item.Modifiers == "public"? String.Empty: item.Modifiers)
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (Model.Enums.Any()) {
    <div class="enumerators">
        <h2>Enumerators</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Enums) {
                    <tr>
                        <td>
                            @(item.Modifiers == "public"? String.Empty: item.Modifiers)
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (Model.Constructors.Any()) {
    <div class="constructors">
        <h2>Constructors</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Constructors) {
                    <tr>
                        <td>
                            @(item.Modifiers.Replace("public", "").Trim())
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (Model.Properties.Any()) {
    <div class="properties">
        <h2>Properties</h2>
        <table class="members">
                <thead>
                    <tr>
                        <th>
                        </th>
                        <th>
                            Name
                        </th>
                        <th>
                            Description
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.Properties) {
                        <tr>
                            <td>
                                @(item.Modifiers.Replace("public", "").Trim())
                            </td>
                            <td>
                                @Html.ApiDocumentationLink(item)
                            </td>
                            <td>
                                @item.Description
                                @if (item.DeclaringType.CRef != Model.CRef) {
                                    <text>
                                    (Inherited from @Html.ApiDocumentationLink(item.DeclaringType)).
                                    </text>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
    </div>
}

@if (Model.Fields.Any()) {
    <div class="fields">
        <h2>Fields</h2>
        <table class="members">
                <thead>
                    <tr>
                        <th>
                        </th>
                        <th>
                            Name
                        </th>
                        <th>
                            Description
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.Fields) {
                        <tr>
                            <td>
                                @(item.Modifiers.Replace("public", "").Trim())
                            </td>
                            <td>
                                @Html.ApiDocumentationLink(item)
                            </td>
                            <td>
                                @item.Description
                                @if (item.DeclaringType.CRef != Model.CRef) {
                                    <text>
                                    (Inherited from @Html.ApiDocumentationLink(item.DeclaringType)).
                                    </text>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
    </div>
}

@if (Model.Methods.Any()) {
    <div class="methods">
        <h2>Methods</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Methods) {
                    <tr>
                        <td>
                            @(item.Modifiers.Replace("public", "").Trim())
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                            @if (item.DeclaringType.CRef != Model.CRef) {
                                <text>
                                (Inherited from @Html.ApiDocumentationLink(item.DeclaringType)).
                                </text>
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (Model.Events.Any()) {
    <div class="events">
        <h2>Events</h2>
        <table class="members">
                <thead>
                    <tr>
                        <th>
                        </th>
                        <th>
                            Name
                        </th>
                        <th>
                            Description
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.Events) {
                        <tr>
                            <td>
                                @(item.Modifiers.Replace("public", "").Trim())
                            </td>
                            <td>
                                @Html.ApiDocumentationLink(item)
                            </td>
                            <td>
                                @item.Description.ToPlainText()
                                @if (item.DeclaringType.CRef != Model.CRef) {
                                    <text>
                                    (Inherited from @Html.ApiDocumentationLink(item.DeclaringType)).
                                    </text>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
    </div>
}

@if (Model.ExtensionMethods.Any()) {
    <div class="methods">
        <h2>Extension Methods</h2>
        <table class="members">
            <thead>
                <tr>
                    <th>
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Description
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.ExtensionMethods) {
                    <tr>
                        <td>
                            @(item.Modifiers.Replace("public", "").Trim())
                        </td>
                        <td>
                            @Html.ApiDocumentationLink(item)
                        </td>
                        <td>
                            @item.Description.ToPlainText()
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@if (!String.IsNullOrEmpty(Model.Example)) {
    <div class="examples">
        <h2>Examples</h2>
        @Model.Example.ToHtml(Url.Action("Index", "ApiDocumentation"))
    </div>
}

@if (!String.IsNullOrEmpty(Model.SeeAlso)) {
    <div class="seeAlso">
        <h2>See Also</h2>
        @Model.SeeAlso.ToHtml(Url.Action("Index", "ApiDocumentation"))
    </div>
}

<!-- Syntax Highligher Scripts -->
<script type="text/javascript" src="~/Scripts/SyntaxHighlighter/shCore.js"></script>
<script type="text/javascript" src="~/Scripts/SyntaxHighlighter/shBrushCSharp.js"></script>
<link href="~/Content/SyntaxHighlighter/shCore.css" rel="stylesheet" type="text/css" />
<link href="~/Content/SyntaxHighlighter/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    SyntaxHighlighter.defaults.toolbar = false;
    SyntaxHighlighter.all();
</script>
